//
//  AcvHonourTableViewCell.m
//  ZiJinLian
//
//  Created by 震霄 张 on 2018/4/6.
//  Copyright © 2018年 lzy. All rights reserved.
//

#import "AcvHonourTableViewCell.h"

@interface AcvHonourTableViewCell()
@property (weak, nonatomic) IBOutlet UILabel *timeLabel;
@property (weak, nonatomic) IBOutlet UILabel *desLabel;
@property (weak, nonatomic) IBOutlet UIImageView *iconView;

@end

@implementation AcvHonourTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
	self.autoresizingMask = UIViewAutoresizingNone;
	
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}
-(void)setModel:(AcvMineHnourModel *)model
{
	_model = model;
	self.timeLabel.text = [self getTimeFromTimestamp:[model.createTime integerValue]];
	[self.iconView sd_setImageWithURL:[NSURL URLWithString:model.eventLogo] placeholderImage:[UIImage imageNamed:@"icon_merits_worship"]];
//	self.desLabel.text = model.DEscription;
//	self.desLabel.attributedText
	NSMutableAttributedString *contentAttr1 = [[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat:@"%@ %@",model.eventName,model.DEscription] attributes:@{     NSFontAttributeName : [UIFont systemFontOfSize:14],NSForegroundColorAttributeName : [UIColor colorWithRed:51.0/255.0 green:51.0/255.0 blue:51.0/255.0 alpha:1]                                                                                               }];
	
	[contentAttr1 addAttribute:NSForegroundColorAttributeName value:Red_Color range:NSMakeRange(0, model.eventName.length)];
	self.desLabel.attributedText = contentAttr1;
	
	
}
-(NSString *)getTimeFromTimestamp:(NSInteger)time{
	

	
	
	//将对象类型的时间转换为NSDate类型
	
	NSDate * myDate=[NSDate dateWithTimeIntervalSince1970:time];
	
	//是否今天
	if ([Utils isToday:myDate]) {
		return @"今天";
	}
	
	
	//设置时间格式
	
	NSDateFormatter * formatter=[[NSDateFormatter alloc]init];
	
	[formatter setDateFormat:@"dd MM月"];
	
	//将时间转换为字符串
	
	NSString *timeStr=[formatter stringFromDate:myDate];
	
	return timeStr;
	
}
@end
